import { ObjectType, transferTimestampToSecond } from '../../../utils';
import { changeTypes, financeSubType, userTypes } from '@/const/risk';

export const columns: ObjectType[] = [
  {
    title: '资金调整单号',
    dataIndex: 'orderId',
    key: 'orderId',
    width: 300,
  },
  {
    title: '账户类型',
    dataIndex: 'userType',
    key: 'userType',
    width: 100,
    render: (text: string, record: ObjectType) => {
      const { userType } = record;
      return userTypes.filter((val: ObjectType) => val.id === userType)[0].text;
    },
  },
  {
    title: '账户名',
    dataIndex: 'username',
    key: 'username',
    width: 150,
  },
  {
    title: '调整类型',
    dataIndex: 'changeType',
    key: 'changeType',
    width: 200,
    render: (text: string, record: ObjectType) => {
      const { changeType } = record;
      return changeTypes.filter((val: ObjectType) => val.id === changeType)[0].text;
    },
  },
  {
    title: '细分类型',
    dataIndex: 'subType',
    key: 'subType',
    width: 150,
    render: (text: string, record: ObjectType) => {
      const { subType } = record;
      return financeSubType.filter((val: ObjectType) => val.id === subType)[0].text;
    },
  },
  {
    title: '调整资金',
    dataIndex: 'amount',
    key: 'amount',
    width: 150,
  },
  {
    title: '需求流水',
    dataIndex: 'freezeAmount',
    key: 'freezeAmount',
    width: 150,
  },
  {
    title: '调整原由',
    dataIndex: 'remark',
    key: 'remark',
    width: 200,
  },
  {
    title: '申请人',
    dataIndex: 'creator',
    key: 'creator',
    width: 150,
  },
  {
    title: '申请时间',
    dataIndex: 'createTime',
    key: 'createTime',
    width: 250,
    render: (text: number) => transferTimestampToSecond(text),
  },
  {
    title: '一审状态',
    dataIndex: 'firstApproveStatus',
    key: 'firstApproveStatus',
    width: 150,
    render: (text: string, record: ObjectType) => {
      // 状态：-1全部，0待审核，1一审通过，2一审未通过，3二审通过，4二审未通过 5搁置 int
      const { status } = record;
      let statusText = '';
      switch (status) {
        case 0:
          statusText = '待审核';
          break;
        case 2:
          statusText = '拒绝';
          break;
        default:
          statusText = '通过';
      }
      return statusText;
    },
  },
  {
    title: '一审人',
    dataIndex: 'firstApprover',
    key: 'firstApprover',
    width: 100,
  },
  {
    title: '一审时间',
    dataIndex: 'firstTime',
    key: 'firstTime',
    width: 250,
    render: (text: number) => transferTimestampToSecond(text),
  },
  {
    title: '二审状态',
    dataIndex: 'secondApproveStatus',
    key: 'secondApproveStatus',
    width: 150,
    render: (text: string, record: ObjectType) => {
      // 状态：-1全部，0待审核，1一审通过，2一审未通过，3二审通过，4二审未通过 5搁置 int
      const { status } = record;
      let statusText = '';
      switch (status) {
        case 1:
          statusText = '待审核';
          break;
        case 3:
          statusText = '审核通过';
          break;
        case 4:
          statusText = '二审未通过';
          break;
        case 5:
          statusText = '审核搁置';
          break;
        default:
          statusText = '';
      }
      return statusText;
    },
  },
  {
    title: '二审人',
    dataIndex: 'secondApprover',
    key: 'secondApprover',
    width: 100,
  },
  {
    title: '二审时间',
    dataIndex: 'secondTime',
    key: 'secondTime',
    width: 250,
    render: (text: number) => transferTimestampToSecond(text),
  },
];
